package web.controller;

import com.alibaba.fastjson.JSON;
import web.controller.base.SuperController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;

public class UserController extends SuperController {

    @Override
    public String execute(HttpServletRequest request, HttpServletResponse response) {
        System.out.println("进入了usercontroller");
        String opr = request.getParameter("opr");
        String url="";
        if ("userList".equals(opr)){
            //转发
            //url="转发:index.jsp";
            url="index.jsp";
            //request.getRequestDispatcher("index.jsp").forward(request,response);
        }else if("login".equals(opr)){
            //response.sendRedirect();
            url="redirect:login.jsp";

        } else if ("updateUser".equals(opr)) {
            ArrayList list= new ArrayList(){
                {add("张三");}
                {add("李四");}
                {add(opr);}
            };
          //  System.out.println(("用户发送的请求信息:: " + JSON.toJSONString(list)));
            url= "out:".concat( JSON.toJSONString(list));

        }
        return url;
    }
}
